<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Uint8</title>
</head>

<body>

  <script type="text/javascript">
    const buffer = new ArrayBuffer(5); // yaoga
    const view = new DataView(buffer);

    // yao
    const str = 'yaogang'
    view.setUint8(0, str.charCodeAt(0))
    view.setUint8(1, str.charCodeAt(1))
    view.setUint8(2, str.charCodeAt(2))
    view.setUint16(3, 0x6761, false) // 'ga'

    console.log(buffer);
  </script>
</body>

</html>